const express = require('express');
const router = new express.Router();

/**
 * @param {Object} options
 * @param {} options.status 整车索赔政策状态  1-新建  2-生效  -1-作废
 * @param {} options.pageSize 每页数据量
 * @param {} options.pageIndex 指定页
 * @param {} options.sortField 排序字段
 * @param {} options.isDesc 倒序排列
 * @throws {Error}
 * @return {Promise}
 */
router.get('/', async(req, res, next) => {
    const options = {
        status: req.query.status,
        pageSize: req.query.pageSize,
        pageIndex: req.query.pageIndex,
        sortField: req.query.sortField,
        isDesc: req.query.isDesc
    };
    const data = {
        message: 'message',
        payload: {
            content: [
                {
                    id: 'id223',
                    rowVersion: 'rowVersion',
                    options: [
                        'update',
                        'abandon',
                        'enable'
                    ],
                    code: 'code224',
                    name: 'name225',
                    startTime: '2019-06-29T05:56:31Z',
                    dealerId: 'dealerId',
                    dealerCode: 'dealerCode',
                    dealerName: 'dealerName',
                    brandId: 'brandId',
                    brandCode: 'brandCode',
                    brandName: 'brandName',
                    remark: 'remark'
                },
                {
                    id: 'id226',
                    rowVersion: 'rowVersion',
                    options: [
                        'update',
                        'abandon',
                        'enable'
                    ],
                    code: 'code227',
                    name: 'name228',
                    dealerId: 'dealerId',
                    dealerCode: 'dealerCode',
                    dealerName: 'dealerName',
                    brandId: 'brandId',
                    brandCode: 'brandCode',
                    brandName: 'brandName',
                    startTime: '2019-06-29T05:56:31Z',
                    remark: 'remark'
                }
            ],
            pageIndex: null,
            pageSize: null,
            sort: null,
            totalElements: 50,
            totalPages: null
        }
    };
    res.json(data);
});

router.post('/import', (req, res) => {
    const data = [];
    for(let i = 1; i < 5; i++)
        data.push({
            id: `${i}`,
            vin: `vin-${i}`
        });
    res.json({
        message: 'ok',
        payload: {
            content: data
        }
    });
});
/**
 * @param {Object} options
 * @throws {Error}
 * @return {Promise}
 */
router.post('/', async(req, res, next) => {
    const options = {
    };
    const data = {
        message: 'message'
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.id 整车索赔政策Id
 * @throws {Error}
 * @return {Promise}
 */
router.get('/:id', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message',
        payload: {
            id: 'id229',
            rowVersion: 'rowVersion',
            options: [
                'update',
                'abandon',
                'enable'
            ],
            code: 'code230',
            name: 'name231',
            dealerId: 'dealerId',
            dealerCode: 'dealerCode',
            dealerName: 'dealerName',
            brandId: 'brandId',
            brandCode: 'brandCode',
            brandName: 'brandName',
            startTime: '2019-06-29T05:56:31Z',
            remark: 'remark',
            items: [
                {
                    id: 'id232',
                    warrantyPolicyType: 1,
                    warrantyMileage: 1,
                    warrantyMonth: 1,
                    saleStartDate: '2019-06-29T05:56:31Z',
                    saleEndDate: '2019-06-29T05:56:31Z',
                    repairValidityMileage: 1,
                    repairValidityPeriod: 1,
                    vehicles: [
                        {
                            id: 'id233',
                            productCategoryId: 'productCategoryId234',
                            productCategoryCode: 'productCategoryCode235',
                            productCategoryName: 'productCategoryName236',
                            vehicleProperty: 1,
                            vehicleId: 'vehicleId236',
                            vin: 'vin',
                            materials: [
                                {
                                    id: 'id237',
                                    partId: 'partId238',
                                    partCode: 'partCode239',
                                    partName: 'partName240',
                                    partWarrantyCategoryId: 'partWarrantyCategoryId241',
                                    partWarrantyCategoryCode: 'partWarrantyCategoryCode242',
                                    partWarrantyCategoryName: 'partWarrantyCategoryName243',
                                    warrantyDuration: 1,
                                    warrantyMileage: 1,
                                    remark: 'remark'
                                }
                            ]
                        }
                    ]
                },
                {
                    id: 'id244',
                    warrantyPolicyType: 1,
                    warrantyMileage: 1,
                    warrantyMonth: 1,
                    saleStartDate: '2019-06-29T05:56:31Z',
                    saleEndDate: '2019-06-29T05:56:31Z',
                    repairValidityMileage: 1,
                    repairValidityPeriod: 1,
                    vehicles: [
                        {
                            id: 'id233',
                            productCategoryId: 'productCategoryId234',
                            productCategoryCode: 'productCategoryCode235',
                            productCategoryName: 'productCategoryName236',
                            vehicleProperty: 1,
                            vehicleId: 'vehicleId236',
                            vin: 'vin',
                            materials: [
                                {
                                    id: 'id237',
                                    partId: 'partId238',
                                    partCode: 'partCode239',
                                    partName: 'partName240',
                                    partWarrantyCategoryId: 'partWarrantyCategoryId241',
                                    partWarrantyCategoryCode: 'partWarrantyCategoryCode242',
                                    partWarrantyCategoryName: 'partWarrantyCategoryName243',
                                    warrantyDuration: 1,
                                    warrantyMileage: 1,
                                    remark: 'remark'
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.id 整车索赔政策Id
 * @throws {Error}
 * @return {Promise}
 */
router.put('/:id', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message'
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.id 整车索赔政策Id
 * @throws {Error}
 * @return {Promise}
 */
router.put('/:id/enable', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message'
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.id 整车索赔政策Id
 * @throws {Error}
 * @return {Promise}
 */
router.put('/:id/abandon', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message'
    };
    res.json(data);
});
module.exports = router;
